home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Sherlock 2.0
/
Sherlock_DevLib
/
sl.h
< prev
next >
Wrap
Text File
|
1996-04-04
|
10KB
|
364 lines
/*
Sherlock master header file.
source: sl.h
started: November 4, 1993.
version:
April 4, 1996.
Added FTAG and FTAGV macros.
February 9, 1996.
Added support for C++.
November 15, 1995.
Added prototypes for sl_mac_xxx.c files.
Added prototype for sl_unwatch.
October 26, 1995
Optionally enalbe hidden Sherlock entry points with HIDDEN_SHERLOCK_ENTRIES.
Septermber 25, 1995
Added support for CodeWarrior.
July 6, 1994.
Added support for Tuple compiler.
January 7, 1994.
*/
/*
Make sure this file is included only once.
*/
#pragma once
#ifndef SHERLOCK_H_
#define SHERLOCK_H_
#ifdef __cplusplus // 2/9/96
extern "C" {
#endif
#define SL_VERSION_NAME "October 25, 1995"
/*
Set SHERLOCK_DEFINED to 0 or 1, depending on whether SHERLOCK is defined.
The sherlock macro includes code only if SHERLOCK is defined.
*/
#ifdef SHERLOCK
#define SHERLOCK_DEFINED 1
#else
#define SHERLOCK_DEFINED 0
#endif
/*
The following constants are predefined by their respective compilers:
applec use MPW on the Macintosh.
THINK_C use THINK_C on the Macintosh 68K.
SYMANTEC_C use SYMANTEC_C on MACintosh PPC.
*/
#include <stdio.h> /* Defines sprintf and size_t. */
#ifdef applec
#if 0 /* Do not include Toolbox code for MPW. */
#include <Types.h> /* Defines Boolean and Point. */
#include <Events.h> /* Defines EventRecord. */
#include <Menus.h> /* Must precede redefinition of Menu Routines. */
#include <Quickdraw.h> /* Defines RgnHandle. */
#endif
#endif
#if defined(THINK_C) || defined(SYMANTEC_C) || defined(__MWERKS__)
#include <Types.h> /* Defines Boolean and Point. */
#include <Errors.h>
#include <Events.h> /* Defines EventRecord. */
#include <OSUtils.h>
#include <Menus.h>
#include <Quickdraw.h> /* Defines RgnHandle. */
#include <SegLoad.h>
#endif
/* 9/25/95 */
#ifndef bool_defined
typedef int bool;
#endif
/*
Define the format of statistics nodes.
These nodes are used to keep all information related to tracepoints.
There is exactly one node per tracepoint, regardless of how many
times a tracepoint name appears throughout the code.
*/
typedef struct sl_node_struct sl_node;
struct sl_node_struct {
sl_node * next; /* pointer to next bucket. */
sl_node * alpha; /* alphabetical list. */
char * name; /* pointer to checkpoint name. */
unsigned long calls; /* # of calls to macros. */
unsigned long time; /* Time (in ticks). */
unsigned long time2; /* Cumulative time. */
int trace; /* trace/wild flags. */
};
#define SL_TRACE_BIT 0x01 /* TRUE: tracing enabled. */
#define SL_WILD_BIT 0x02 /* TRUE: enabled by wildcard. */
typedef struct sl_watch_struct sl_wnode;
struct sl_watch_struct {
sl_wnode * wnext;
char * wp; /* Pointer to the current block. */
char * wsavep; /* Pointer to the saved block. */
long wlength; /* Length of both blocks. */
char * wtag;
};
extern sl_wnode * sl_wlist;
/*
Global Sherlock variables.
*/
extern long sl_theTicks; /* Ticks returned from sl_ret */
extern long sl_min_margin; /* Minimum stack margin. */
extern long sl_margin_start; /* Stack area (maximum stack margin). */
extern bool sl_time_flag; /* TRUE: report time in exit macros. */
extern bool sl_use_adjust_flag; /* TRUE: adjust time statistics in sl_dump.c. */
extern unsigned long sl_count; /* Time returned by interrupt routines. */
/*
Function prototypes.
*/
/* sl_dump.c */
/* Aliases for values of TRUE and FALSE in flags. */
#define SL_DUMP_ALL_STATS TRUE
#define SL_DUMP_ENABLED_STATS FALSE
void sl_dump (void);
void sl_dump_header (bool dump_all_flag);
void sl_dump_name (char * name);
void sl_dump_names (bool dump_all_flag, char * dump_name);
void sl_dump_start (void);
void sl_dump_subtotals(void);
void sl_dump_subtotal_start(void);
void sl_dump_totals (void);
void sl_dump_wild (void);
void sl_edump (void);
void sl_dumpstk (void);
void sl_hdump (void);
/* sl_init.c */
void sl_init (char * version);
void sl_off (char *);
void sl_on (char *);
void sl_parse (int *,char **,char *,char *);
int sl_match (char *s1, char *s2);
void sl_signon (void);
int sl_wild (char *s);
/* sl_macro.c */
sl_node * sl_find_name(char *s);
void sl_ovb (void);
void sl_ovx (void);
int sl_pxtrace (char *); /* TRACEPX */
void sl_unwatch (char * p, long length);
void sl_watch (void * p, long length, char * tag);
void sl_watchall (void);
void sl_x (char *); /* TICKX */
bool sl_xb (char *,bool);
char sl_xc (char *,char);
double sl_xd (char *,double);
double sl_xf (char *,double);
int sl_xi (char *,int);
long sl_xl (char *,long);
void * sl_xp (char *,void *);
char * sl_xs (char *,char *);
int sl_xtrace (char *); /* TRACEX */
unsigned int sl_xui (char *,unsigned int);
unsigned long sl_xul (char *,unsigned long);
void sl_xv (char *);
void sl2bstat (sl_node **,char *);
void sl2btick (sl_node **,char *);
int sl2btrace (sl_node **,char *);
int sl2not (sl_node **,char *);
void sl2ntick (sl_node **,char *);
int sl2ntrace (sl_node **,char *);
int sl2pbtrace (sl_node **,char *);
int sl2pntrace (sl_node **,char *);
int sl2ptrace (sl_node **,char *);
void sl2stat (sl_node **,char *);
void sl2tick (sl_node **,char *);
int sl2trace (sl_node **,char *);
/* sl_time.c */
unsigned long sl_adjust(sl_node * np, long val);
void sl_setadj (void);
void sl_timetest (void);
/* sl_util.c */
char * sl_callname (int n);
void sl_clear (void);
void sl_setname (char *);
/* sl_mac_menu.c, sl_mac_window.c */
void sl_enable_menu_items (void);
void sl_do_command (short item);
void sl_install_sherlock_menu (void);
/*
The SL_ENABLE and SL_DISABLE macros are used as signals to SPP.
They must always be defined and must never produce any expansion.
*/
#define SL_DISABLE()
#define SL_ENABLE()
/*
Define the actual Sherlock macros.
Sherlock macros produce "do nothing" code if SHERLOCK is not #define'd.
*/
#ifdef SHERLOCK
#ifndef FTAG
#define FTAG(s) char * ftag = s
#endif
#ifndef FTAGV
#define FTAGV(s) char * ftagv = s
#endif
#define SL_CALLNAME(n) sl_callname(n)
#define SL_CLEAR() sl_clear()
#define SL_DUMP() sl_dump()
#define SL_INIT() sl_init(SL_VERSION_NAME)
#define SL_NAME(a,b) static char a [] = b
#define SL_NOT(a,b) {static sl_node *sl_h_=0; if(!sl2ntrace(&sl_h_,a)){b;}}
#define SL_NOTP(a,b) {static sl_node *sl_h_=0; if(!sl2pntrace(&sl_h_,a)){b;}}
#define SL_OFF(s) sl_off(s)
#define SL_ON(s) sl_on(s)
#define SL_OVB() sl_ovb()
#define SL_OVX() sl_ovx()
#define SL_PARSE(argc,argv,on,off) sl_parse(&argc,argv,on,off)
#define SL_SIGNON() sl_signon()
#define SL_WATCH(a,b,c) sl_watch(a,b,c)
#define SL_WATCH_ALL() sl_watch_all()
#define STAT(a) {static sl_node *sl_h_=0; sl2stat(&sl_h_,a);}
#define STATB(a) {static sl_node *sl_h_=0; sl2bstat(&sl_h_,a);}
#define STATX(a) {sl_xtrace(a);} /* Ignore the return code. */
#define TICK(a) {static sl_node *sl_h_=0; sl2tick(&sl_h_,a);}
#define TICKB(a) {static sl_node *sl_h_=0; sl2btick(&sl_h_,a);}
#define TICKN(a) {static sl_node *sl_h_=0; sl2ntick(&sl_h_,a);}
#define TICKX(a) sl_x(a)
#define TICKX_BOOL(a,b) sl_xb(a,b)
#define TICKX_CHAR(a,c) sl_xc(a,c)
#define TICKX_DOUBLE(a,d) sl_xd(a,d)
#define TICKX_FLOAT(a,f) sl_xf(a,f)
#define TICKX_INT(a,i) sl_xi(a,i)
#define TICKX_LONG(a,l) sl_xl(a,l)
#define TICKX_PTR(a,p) sl_xp(a,p)
#define TICKX_STRING(a,s) sl_xs(a,s)
#define TICKX_UINT(a,u) sl_xui(a,u)
#define TICKX_ULONG(a,u) sl_xul(a,u)
#define TICKX_VOID(a) sl_xv(a)
#define TRACE(a,b) {static sl_node *sl_h_=0; if(sl2trace(&sl_h_,a)) {b;}}
#define TRACEB(a,b) {static sl_node *sl_h_=0; if(sl2btrace(&sl_h_,a)){b;}}
#define TRACEN(a,b) {static sl_node *sl_h_=0; if(sl2ntrace(&sl_h_,a)){b;}}
#define TRACEX(a,b) {if(sl_xtrace(a)) {b;}}
#define TRACEP(a,b) {static sl_node *sl_h_=0; if(sl2ptrace(&sl_h_,a)) {b;}}
#define TRACEPB(a,b) {static sl_node *sl_h_=0; if(sl2pbtrace(&sl_h_,a)){b;}}
#define TRACEPN(a,b) {static sl_node *sl_h_=0; if(sl2pntrace(&sl_h_,a)){b;}}
#define TRACEPX(a,b) {if(sl_pxtrace(a)) {b;}}
/*
No calls to the following Macintosh traps should appear outside of mac_gui.c.
The following macros make *sure* they do not.
*/
#if defined(THINK_C) || defined(SYMANTEC_C) || defined(__MWERKS__)
#ifdef HIDDEN_SHERLOCK_ENTRIES
#define GetNextEvent(a,b) w_event(a,b,0L,((RgnHandle)0),0)
#define WaitNextEvent(a,b,c,d) w_event(a,b,c,d,1)
#define MenuSelect(a) w_menuSelect(a)
#define DrawMenuBar() w_drawMenuBar()
#endif
#endif
#else /* SHERLOCK not defined. */
/* Null macro definitions for all Sherlock macros. */
#ifndef FTAG
#define FTAG(s) char * ftag = NULL
#endif
#ifndef FTAGV
#define FTAGV(s) char * ftag = NULL
#endif
#define SL_CALLNAME(n) ""
#define SL_CLEAR()
#define SL_DUMP()
#define SL_INIT()
#define SL_MAC_INIT(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r)
#define SL_NAME(a,b)
#define SL_NOT(a,b)
#define SL_NOTP(a,b)
#define SL_OFF(s)
#define SL_ON(s)
#define SL_OVB()
#define SL_OVX()
#define SL_PARSE(argc,argv,on,off)
#define SL_SIGNON()
#define SL_WATCH(a,b,c)
#define SL_WATCH_ALL()
#define STAT(a)
#define STATB(a)
#define STATX(a)
#define TICK(a)
#define TICKB(a)
#define TICKN(a)
#define TICKX(a)
#define TICKX_BOOL(a,b)
#define TICKX_CHAR(a,c)
#define TICKX_DOUBLE(a,d)
#define TICKX_FLOAT(a,f)
#define TICKX_INT(a,i)
#define TICKX_LONG(a,l)
#define TICKX_PTR(a,p)
#define TICKX_STRING(a,s)
#define TICKX_UINT(a,u)
#define TICKX_ULONG(a,u)
#define TICKX_VOID(a)
#define TRACE(a,b)
#define TRACEB(a,b)
#define TRACEN(a,b)
#define TRACEX(a,b)
#define TRACEP(a,b)
#define TRACEPB(a,b)
#define TRACEPN(a,b)
#define TRACEPX(a,b)
#endif /* ifdef SHERLOCK */
#ifdef __cplusplus // 2/9/96
}
#endif
#endif /* ifndef SHERLOCK_H_ */